<template>
    <div>
        <!-- banner -->
        <div class="category-banner banner">
            <h1 class="banner-title">时间</h1>
        </div>
        <v-card class="blog-container">
            <div class="textCon">
            <div class="words">今天是我们在一起的</div>
            <div class="days">
                <span class="days-number">{{ day }}</span>
                <span class="days-label">天</span>
            </div>
            <div class="seconds">{{ time }}</div>
            <div class="heart"></div>
        </div>
        </v-card>
    </div>

</template>
<script>
export default {
    created() {
        window.setInterval(this.timerStart, 1000);
        this.timerStart();
    },
    data: function () {
        return {
            day: '',
            time: ''
        };
    },
    methods: {
        timerStart() {
            var arr = "2022-05-03 00:00:00".split(/[- :]/);//改这里
            var start_time = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5]);
            var duration = parseInt(new Date() - start_time) / 1000;
            var seconds = parseInt(duration % 60);
            if (seconds < 10)
                seconds = "0" + seconds;
            duration = parseInt(duration / 60);
            var minutes = duration % 60;
            if (minutes < 10)
                minutes = "0" + minutes;
            duration = parseInt(duration / 60);
            var hours = duration % 24;
            if (hours < 10)
                hours = "0" + hours;
            duration = parseInt(duration / 24);
            var days = duration;
            this.day = days;
            this.time = (hours + " 时 " + minutes + " 分 " + seconds + " 秒");
        }
    }
}
</script>
<style scoped>
* {
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    /*text-align: center;*/
    background-color: #ffc5b3;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);
    -o-transform: translate(-50%, -50%);
    background-image: radial-gradient(#ffeded, #ffc7c7);
}

.textCon {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    width: 700px;
    height: 450px;
    margin: 0 auto;
}

.text {
    font-size: 48px;
}

.heart {
    width: 80px;
    height: 80px;
    background-color: #cc2a5d;
    margin: 100px auto;
    position: relative;
    transform: rotate(45deg);
    animation: heart 1s ease-in infinite;
}

.heart::before,
.heart::after {
    content: '';
    width: 100%;
    height: 100%;
    background-color: #cc2a5d;
    border-radius: 50%;
}

.heart::before {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(-50%);
}

.heart::after {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(-50%);
}

@keyframes heart {
    0% {
        transform: scale(0.8) rotate(45deg);
        opacity: 0.8;
    }

    50% {
        transform: scale(1) rotate(45deg);
        opacity: 1;
    }

    100% {
        transform: scale(0.8) rotate(45deg);
        opacity: 0.8;
    }
}

.textCon .item {
    position: absolute;
    opacity: 0;
    background-color: #cc2a5d;
    transform: rotate(45deg);
    animation: hearts 3s ease-in infinite;
}

.textCon .item::before,
.textCon .item::after {
    content: '';
    width: 100%;
    height: 100%;
    background-color: #cc2a5d;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
}

.textCon .item::before {
    transform: translateX(-50%);
}

.textCon .item::after {
    transform: translateY(-50%);
}

@keyframes hearts {
    0% {
        opacity: 0;
        transform: translateY(0%) rotate(45deg);
    }

    20% {
        opacity: 0.8;
        transform: translateY(-20%) rotate(45deg);
    }

    100% {
        opacity: 0;
        transform: translateY(-1000%) rotate(45deg);
    }
}

.days-label {
    font-size: 40px;
    font-family: 'Regular', cursive;
}

.days-number {
    font-family: 'Regular', cursive;
}

.seconds {
    margin-top: 10px;
    font-size: 32px;
    font-family: 'Regular', cursive;
    width: auto;
    text-align: center;
}

.seconds-label {
    margin-top: 32px;
    font-size: 32px;
    font-family: 'Regular', cursive;
    width: auto;
    text-align: center;
}

.container {
    position: absolute;
}

.days {
    font-size: 40px;
    width: auto;
    text-align: center;
}

.words {
    font-size: 50px;
    font-family: 'Regular', cursive;
    width: auto;
    text-align: center;
}
</style>